<template>
	<div class="global-setting">
	<affix label="工单信息推送设置">
		<el-form ref='form' :model="form" label-position="top" size="small">
			<el-form-item label="是否开启工单信息推送失败重推" prop="businessInfoPushConfig" style="height: 40px">
				<el-radio-group v-model="form.businessInfoPushConfig">
					  <el-radio :label="true">是</el-radio>
            <el-radio :label="false">否</el-radio>
				</el-radio-group>
			</el-form-item>
      <el-form-item label="工单流出接口推送满意度链接" prop="businessSatisfiedConfig" style="height: 40px">
        <el-radio-group v-model="form.businessSatisfiedConfig" :disabled="isDisable">
          <el-radio :label="true">是</el-radio>
          <el-radio :label="false">否</el-radio>
        </el-radio-group>
      </el-form-item>
			<el-form-item style="text-align: right">
				        <el-button class="primary_btn"
                   type="primary"
                   size="mini"
                   @click.stop="save">保存</el-button>
			</el-form-item>
		</el-form>
	</affix>
	</div>
</template>

<script>
import Affix from '@components/ui-modules/affix/Affix.vue';
export default {
  name: 'busGloablSetting',
  data () {
    return {
      isDisable: false,
      form: {
        businessInfoPushConfig: false,
        businessSatisfiedConfig: false
      }
    }
  },
  components: {
    Affix
  },
  methods: {
    getConfig () {
      this.$store.dispatch('queryBusinessInfoPushConfig', {}).then((res) => {
        if (res.success) {
          this.form.businessInfoPushConfig = res.pushConfig || false
          if (res.satisfiedFlag) {
            this.form.businessSatisfiedConfig = res.satisfiedConfig || false
          } else {
            this.isDisable = true
            this.form.businessSatisfiedConfig = false
          }
        }
      })
    },
    save () {
      this.$store.dispatch('updateBusinessInfoPushConfig', this.form).then((res) => {
        if (res.success) {
          this.$message.success('保存成功')
        }
      })
    }
  },
  beforeMount () {
    this.getConfig()
  }
}
</script>

<style scoped lang='stylus'>
	.global-setting
		padding 20px
</style>
